﻿using System;

namespace TUtils.BasicHelper.Logging
{
	public class LogValue : ILogValue
	{
		public ILoggingValueKey Key
		{
			get;
			private set;
		}

		private string _logValue;
		public string Value
		{
			get
			{
				if (_logValue == null)
					_logValue = _getLogText();
				return _logValue;
			}
		}

		private Func<string> _getLogText;

		private LogValue(ILoggingValueKey loggingValueKey)
		{
			Key = loggingValueKey;
		}

		public LogValue(ILoggingValueKey loggingValueID, string logValue)
			: this(loggingValueKey: loggingValueID)
		{
			_logValue = logValue;
		}
		public LogValue(ILoggingValueKey loggingValueID, Func<string> getLogValue)
			: this(loggingValueKey: loggingValueID)
		{
			_getLogText = getLogValue;
		}

	}
}